var t = require("../../../3D336854875DE5CF5B550053BF4D6824.js"), o = (getApp().globalData, 
null), e = null;

Page({
    data: {
        type: "word",
        filePath: "",
        arr: [],
        text: ""
    },
    onLoad: function(t) {
        null != t.filePath && (e = t.filePath, this.recognizeWord(e)), this.loadInterstitialAd();
    },
    loadInterstitialAd: function() {
        wx.createInterstitialAd && ((o = wx.createInterstitialAd({
            adUnitId: "adunit-e913ba6604ebbeae"
        })).onLoad(function() {
            console.log("ad onLoad event emit");
        }), o.onError(function(t) {
            console.log("ad onError event emit");
        }), o.onClose(function(t) {
            console.log("ad onClose event emit");
        }));
    },
    showInterstitialAd: function() {
        o && o.show().catch(function(t) {
            console.log("插屏广告显示失败"), console.error(t);
        });
    },
    recognizeWord: function(o) {
        var e = this;
        t.recognizeWord(o, "word").then(function(t) {
            if (t) {
                console.log("detail words:"), console.log(t);
                var n = "";
                if (200 != t.code) return e.setData({
                    text: ""
                }), void wx.showModal({
                    title: "提示",
                    content: t.message,
                    showCancel: !1,
                    complete: function(t) {
                        t.confirm && wx.navigateBack();
                    }
                });
                var a = t.result;
                a.length > 1 ? n = a.join("\n") : 1 == a.length && (n = a[0]), console.log("text:", n);
                var i = util.todayDate() + "_close_ad", l = wx.getStorageSync(i) || !1;
                console.log("是否关闭今日广告:" + l), 0 == l && e.showInterstitialAd(), e.setData({
                    filePath: o,
                    text: n
                });
            } else wx.showToast({
                title: "无法识别"
            });
        }).catch(function(t) {});
    },
    copyWord: function(t) {
        var o = t.currentTarget.dataset.text;
        wx.setClipboardData({
            data: o,
            success: function(t) {
                wx.getClipboardData({
                    success: function() {
                        wx.showToast({
                            title: "复制成功"
                        });
                    }
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    previewImage: function(t) {
        wx.previewImage({
            urls: this.data.filePath.split(",")
        });
    },
    chooseImageByCamera: function() {
        var o = this.data.type;
        t.chooseImageByCamera(o);
    },
    chooseImageByAlbum: function() {
        var o = this.data.type;
        t.chooseImageByAlbum(o);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});